<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>分步表单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
    <link rel="stylesheet" href="../js/lay-module/step-lay/step.css" media="all">
    <link rel="stylesheet" href="../js/lay-module/cascader/cascader.css" media="all">
    <link rel="stylesheet" href="../css/pms/release_product.css">

    <link rel="stylesheet" href="../lib/layui-v2.5.5/css/modules/tag.css">


</head>
<body>
<!--<h2>这是发布商品页面</h2>-->
<div class="layuimini-container">
    <div class="layuimini-main">

        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-card-body" style="padding-top: 40px;">
                    <div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto;">
                        <div carousel-item class="carousel-item">
                            <!--基本信息-->
                            <div>
                                <form class="layui-form" style="margin: 0 auto;max-width: 600px;padding-top: 40px;">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label layui-required">商品名称</label>
                                        <div class="layui-input-block">
                                            <!--<input type="text" class="layui-input" placeholder="请输入商品名称"
                                                   lay-verify="required"/>-->
                                            <!--测试先不加lay-verify="required"-->
                                            <input type="text" class="layui-input" placeholder="请输入商品名称"/>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label layui-required">商品描述</label>
                                        <div class="layui-input-block">
                                            <textarea placeholder="请输入内容" class="layui-textarea"
                                                     ></textarea>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label layui-required">选择分类</label>
                                        <div class="layui-input-block">
                                            <input type="text" id="a" class="layui-input" readonly="readonly"
                                                   placeholder="请选择：">
                                        </div>
                                    </div>

                                    <div class="layui-form-item">
                                        <label class="layui-form-label layui-required">选择品牌</label>
                                        <div class="layui-input-block">
                                            <select  placeholder="选择品牌">
                                                <option value="">请选择</option>
                                                <option value="1">华为</option>
                                                <option value="2">小米</option>
                                                <option value="3">OPPO</option>
                                                <option value="4">Apple</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label layui-required">商品重量(kg)</label>
                                        <div class="layui-input-block">
                                            <input type="number" class="layui-input"
                                                   placeholder="0.000"
                                                   value="" min="0" onkeyup="checknum(this);">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label layui-required">商品介绍</label>
                                        <div class="layui-input-block">
                                            <div class="div_imgall">
                                                <button type="button" class="layui-btn layui-btn-primary"
                                                        id="upload_img">上传图片
                                                </button>
                                                <div class="div_shuline"></div>
                                                <div class="div_hengline"></div>
                                            </div>
                                        </div>
                                        <!--预览图片-->
                                        <div id="upload_img_list"></div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label layui-required">商品图集</label>
                                        <div class="layui-input-block">
                                            <div class="div_imgall">
                                                <button type="button" class="layui-btn layui-btn-primary"
                                                        id="upload_img02">上传图片
                                                </button>
                                                <div class="div_shuline"></div>
                                                <div class="div_hengline"></div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="layui-form-item">
                                        <div class="layui-input-block">

                                            <button class="layui-btn" lay-submit lay-filter="formStep">
                                                &emsp;下一步：设置规格参数&emsp;
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <!--规格参数-->
                            <div>
                                <form class="layui-form form02" style="margin: 0 auto;max-width: 800px;padding-top: 40px;">

                                    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                                        <ul class="layui-tab-title">
                                            <li class="layui-this">主体</li>
                                            <li>基本信息</li>
                                            <li>主芯片</li>
                                        </ul>
                                        <div class="layui-tab-content" style="height: 100px;">
                                            <div class="layui-tab-item layui-show">
                                                <div class="layui-form-item layui-row">
                                                    <label class="layui-form-label">入网型号</label>
                                                    <div class="layui-inline">
                                                        <div class="layui-input-block inputBlock" id="test1"></div>
                                                    </div>
                                                    <input type="checkbox" name="01" lay-skin="primary" title="快速展示">

                                                </div>
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">上市年号</label>
                                                    <div class="layui-inline">
                                                        <div class="layui-input-block inputBlock" id="test2"></div>
                                                    </div>
                                                    <input type="checkbox" name="02" lay-skin="primary" title="快速展示">
                                                </div>

                                            </div>
                                            <div class="layui-tab-item">
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">机身颜色</label>
                                                    <div class="layui-inline">
                                                        <div class="layui-input-block inputBlock" id="test3"></div>
                                                    </div>
                                                    <input type="checkbox" name="03" lay-skin="primary" title="快速展示">
                                                </div>
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">机身长度(mm)</label>
                                                    <div class="layui-inline">
                                                        <div class="layui-input-block inputBlock" id="test4"></div>
                                                    </div>
                                                    <input type="checkbox" name="04" lay-skin="primary" title="快速展示">
                                                </div>
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">机身材质工艺</label>
                                                    <div class="layui-inline">
                                                        <div class="layui-input-block inputBlock" id="test5"></div>
                                                    </div>
                                                    <input type="checkbox" name="05" lay-skin="primary" title="快速展示">
                                                </div>
                                            </div>
                                            <div class="layui-tab-item">
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">CPU品牌</label>
                                                    <div class="layui-inline">
                                                        <div class="layui-input-block inputBlock" id="test6"></div>
                                                    </div>
                                                    <input type="checkbox" name="07" lay-skin="primary" title="快速展示">
                                                </div>
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">CPU型号</label>
                                                    <div class="layui-inline">
                                                        <div class="layui-input-block inputBlock" id="test7"></div>
                                                    </div>
                                                    <input type="checkbox" name="07" lay-skin="primary" title="快速展示">
                                                </div>

                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-input-block guige">
                                            <button type="button" class="layui-btn layui-btn-primary pre">上一步</button>
                                            <button class="layui-btn" lay-submit lay-filter="formStep2">
                                                &emsp;下一步：设置销售属性&emsp;
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <!--销售属性-->
                            <div>
                                <form id="sale" class="layui-form" style="margin: 0 auto;max-width: 650px;padding-left: 60px;padding-top: 40px;">

                                    <fieldset class="layui-elem-field">
                                        <legend>选择销售属性</legend>
                                        <div class="layui-field-box">
                                            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                                                <legend>颜色</legend>
                                            </fieldset>
                                            <div class="layui-btn-container tag" lay-filter="demo" lay-allowclose="true" lay-newTag="true">
                                                <button lay-id="11" type="button" class="tag-item">黑色</button>
                                                <button lay-id="22" type="button" class="tag-item">白色</button>
                                                <button lay-id="33" type="button" class="tag-item">蓝色</button>
                                                <button lay-id="44" type="button" class="tag-item">星河银</button>
                                                <button lay-id="55" type="button" class="tag-item">亮黑色</button>
                                            </div>

                                            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                                                <legend>内存</legend>
                                            </fieldset>
                                            <div class="layui-btn-container tag" lay-filter="demo" lay-allowclose="true" lay-newTag="true">
                                                <button lay-id="11" type="button" class="tag-item">4GB</button>
                                                <button lay-id="22" type="button" class="tag-item">6GB</button>
                                                <button lay-id="33" type="button" class="tag-item">8GB</button>
                                                <button lay-id="44" type="button" class="tag-item">12GB</button>
                                            </div>

                                            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                                                <legend>版本</legend>
                                            </fieldset>
                                            <div class="layui-btn-container tag" lay-filter="demo" lay-allowclose="true" lay-newTag="true">
                                                <button lay-id="11" type="button" class="tag-item">8GB+128GB</button>
                                                <button lay-id="22" type="button" class="tag-item">8GB+256GB</button>
                                            </div>
                                        </div>

                                    </fieldset>
                                    <div class="layui-form-item">
                                        <div class="layui-input-block" style="margin-left: 50px;">
                                            <button type="button" class="layui-btn layui-btn-danger pre">上一步</button>
                                            <button class="layui-btn" lay-submit lay-filter="formStep3">
                                                &emsp;下一步：设置SKU信息&emsp;
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <!--SKU信息-->
                            <div>
                                <form class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">游戏ID:</label>
                                        <div class="layui-input-block">
                                            <div class="layui-form-mid layui-word-aux">639537</div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">账户余额:</label>
                                        <div class="layui-input-block">
                                            <div class="layui-form-mid layui-word-aux">3000 元（保险箱：1000，现金：2000）</div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">入款金额:</label>
                                        <div class="layui-input-block">
                                            <div class="layui-form-mid layui-word-aux">
                                                <span style="font-size: 18px;color: #333;">1800 元</span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">入款类型:</label>
                                        <div class="layui-input-block">
                                            <div class="layui-form-mid layui-word-aux">保险箱</div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">入款方式:</label>
                                        <div class="layui-input-block">
                                            <div class="layui-form-mid layui-word-aux">人工入款</div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">备注说明:</label>
                                        <div class="layui-input-block">
                                            <div class="layui-form-mid layui-word-aux">备注说明</div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button type="button" class="layui-btn layui-btn-primary pre">上一步</button>
                                            <button class="layui-btn" lay-submit lay-filter="formStep4">
                                                &emsp;确认发布&emsp;
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <!--保存完成-->
                            <div>
                                <div style="text-align: center;margin-top: 90px;">
                                    <i class="layui-icon layui-circle"
                                       style="color: white;font-size:30px;font-weight:bold;background: #52C41A;padding: 20px;line-height: 80px;">&#xe605;</i>
                                    <div style="font-size: 24px;color: #333;font-weight: 500;margin-top: 30px;">
                                        商品发布成功
                                    </div>
                                    <div style="font-size: 14px;color: #666;margin-top: 20px;">预计两小时到账</div>
                                </div>
                                <div style="text-align: center;margin-top: 50px;">
                                    <button class="layui-btn next">再发布一款</button>
                                    <button class="layui-btn layui-btn-primary">查看商品信息</button>
                                </div>
                            </div>


                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>


<script src="../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="../js/lay-module/cascader/cascader.js"></script>
<script src="../lib/layui-v2.5.5/lay/modules/tag.js"></script>

<script>
    layui.config({base: '../js/lay-module/'}).extend({
        selectInput: 'selectInput/selectInput'
    }).use(['form', 'selectInput', 'element', 'step'], function () {
        var $ = layui.$, form = layui.form, element = layui.element, selectInput = layui.selectInput;
        //Tab的切换功能，切换事件监听等，需要依赖element模块
        //selectInput后台取数据及提交详情转:https://fly.layui.com/extend/selectInput/#doc
        var ins1 = selectInput.render({
            elem: '#test1',
            data: [
                {value: 1111, name: 1111},
                {value: 2333, name: 2222},
                {value: 2333, name: 2333},
                {value: 2333, name: 2333},
            ],
            placeholder: '请选择或输入值',
            name: 'list_common01',
            remoteSearch: false,
            hasSelectIcon: true,
        });
        var ins2 = selectInput.render({
            elem: '#test2',
            data: [
                {value: 1111, name: 1111},
                {value: 2333, name: 2222},
                {value: 2333, name: 2333},
                {value: 2333, name: 2333},
            ],
            placeholder: '请选择或输入值',
            name: 'list_common02',
            remoteSearch: false,
            hasSelectIcon: true,
        });
        var ins3 = selectInput.render({
            elem: '#test3',
            data: [
                {value: 1111, name: 1111},
                {value: 2333, name: 2222},
                {value: 2333, name: 2333},
                {value: 2333, name: 2333},
            ],
            placeholder: '请选择或输入值',
            name: 'list_common03',
            remoteSearch: false,
            hasSelectIcon: true,
        });
        var ins4 = selectInput.render({
            elem: '#test4',
            data: [
                {value: 1111, name: 1111},
                {value: 2333, name: 2222},
                {value: 2333, name: 2333},
                {value: 2333, name: 2333},
            ],
            placeholder: '请选择或输入值',
            name: 'list_common04',
            remoteSearch: false,
            hasSelectIcon: true,
        });
        var ins5 = selectInput.render({
            elem: '#test5',
            data: [
                {value: 1111, name: 1111},
                {value: 2333, name: 2222},
                {value: 2333, name: 2333},
                {value: 2333, name: 2333},
            ],
            placeholder: '请选择或输入值',
            name: 'list_common05',
            remoteSearch: false,
            hasSelectIcon: true,
        });
        var ins6 = selectInput.render({
            elem: '#test6',
            data: [
                {value: 1111, name: 1111},
                {value: 2333, name: 2222},
                {value: 2333, name: 2333},
                {value: 2333, name: 2333},
            ],
            placeholder: '请选择或输入值',
            name: 'list_common06',
            remoteSearch: false,
            hasSelectIcon: true,
        });
        var ins7 = selectInput.render({
            elem: '#test7',
            data: [
                {value: 1111, name: 1111},
                {value: 2333, name: 2222},
                {value: 2333, name: 2333},
                {value: 2333, name: 2333},
            ],
            placeholder: '请选择或输入值',
            name: 'list_common07',
            remoteSearch: false,
            hasSelectIcon: true,
        });

    });


</script>

<script>
    layui.use(['form', 'step'], function () {
        var $ = layui.$,
            form = layui.form,
            step = layui.step,
            cascader = layui.cascader;

        //step滑动div
        step.render({
            elem: '#stepForm',
            filter: 'stepForm',
            width: '100%', //设置容器宽度
            stepWidth: '750px',
            height: '800px',
            stepItems: [{
                title: '基本信息'
            }, {
                title: '规格参数'
            }, {
                title: '销售属性'
            }, {
                title: 'SKU信息'
            }, {
                title: '保存完成'
            }]
        });

        //1.基本信息各组件
        //cascader选择分类联级
        var data02 = [
            {
                value: 'A',
                label: '图书、音像、电子书刊',
                children: [
                    {
                        value: 'AA1',
                        label: '电子书刊',
                    },
                    {
                        value: 'BB1',
                        label: '音像'
                    }
                ]
            },
            {
                value: 'B',
                label: '手机',
                children: [
                    {
                        value: 'AA2',
                        label: '手机通讯',
                        children: [
                            {
                                value: 'AAA3',
                                label: '手机',
                            },
                            {
                                value: 'BBB3',
                                label: '对讲机'
                            }
                        ]
                    },
                    {
                        value: 'BB2',
                        label: '运营商',
                        children: [
                            {
                                value: 'AAA4',
                                label: '合约机',
                            },
                            {
                                value: 'BBB4',
                                label: '选号中心'
                            }
                        ]
                    }
                ]
            },
            {
                value: 'C',
                label: '家用电器',
            }
        ]
        var cas = cascader({
            elem: "#a",
            data: data02,
            // url: "/aa",
            // type: "post",
            // triggerType: "change",
            // showLastLevels: true,
            // where: {
            //     a: "aaa"
            // },
            //value: ["B", "BB2", "BBB4"],
            // changeOnSelect: true,
            success: function (valData, labelData) {
                console.log(valData, labelData);
            }
        });

        //2.规格参数各组件

        //3.销售属性各组件

        //4.SKU信息各组件


        //1.提交基本信息表单
        form.on('submit(formStep)', function (data) {
            step.next('#stepForm');
            return false;
        });

        //2.提交规格参数表单
        form.on('submit(formStep2)', function (data) {
            step.next('#stepForm');
            return false;
        });

        //3.提交销售属性表单
        form.on('submit(formStep3)', function (data) {
            step.next('#stepForm');
            return false;
        });

        //4.提交SKU信息表单
        form.on('submit(formStep4)', function (data) {
            step.next('#stepForm');
            return false;
        });

        //上一步
        $('.pre').click(function () {
            step.pre('#stepForm');
        });

        //下一步
        $('.next').click(function () {
            step.next('#stepForm');
        });
    })
</script>

<script>
    //商品重量只能输入最大精度为3为的小数或者整数
    function checknum(obj) {
        if (/^\d+\.?\d{0,3}$/.test(obj.value)) {
            obj.value = obj.value;
        } else {
            obj.value = obj.value.substring(0, obj.value.length - 1);
        }
    }
</script>
</body>

<script src="../js/pms/release_product.js"></script>
</html>